import {AzraelFrameWorkComponent} from "../Base/AzraelFrameWork";
import {IEventManager} from "../../src/Event/IEventManager";
import GameFrameworkEntry from "../../src/Base/GameFrameworkEntry";
import GameEventArgs from "../../src/Event/GameEventArgs";
import EventManager from "../../src/Event/EventManager";
const {ccclass,property} = cc._decorator;
@ccclass
export default class EventComponent extends AzraelFrameWorkComponent{

    private  _eventManager:IEventManager = null;

    protected onLoad(): void {
        super.onLoad();
        this._eventManager = GameFrameworkEntry.GetModule(EventManager);
    }

    get EventHandlerCount(){
        return this._eventManager.EventHandlerCount();
    }

    get EventCount(){
        return this._eventManager.EventCount();
    }

    Count(id:number):number{
        return this._eventManager.Count(id);
    }

    Check(id:number,handler:(sender,e)=>void):boolean
    {
        return this._eventManager.Check(id,handler);
    }

    Subscribe(id:number,handler:(sender,e)=>void):void{
        this._eventManager.Subscribe(id,handler);
    }

    Unsubscribe(id:number,handler:(sender,e)=>void):void{
        this._eventManager.Unsubscribe(id,handler);
    }

    SetDefaultHandler(handler:(sender,e)=>void):void{
        this._eventManager.SetDefaultHandler(handler);
    }

    Fire(sender,e:GameEventArgs):void{
        this._eventManager.Fire(sender,e);
    }

    FireNow(sender,e:GameEventArgs):void{
        this._eventManager.FireNow(sender, e);
    }

}
